﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Model
{
    class WorkGroupConverter : TypeConverter
    {

        #region Convert To Methods

        public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
        {
            return destinationType == typeof(String);
        }

        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            WorkGroup charValue = (WorkGroup)value;

            switch (charValue.Group_no)
            {
                case 1:
                    return "默认组（1）";
                case 2:
                    return "默认组（2）";
                case 3:
                    return "默认组（3）";
            }

            return base.ConvertTo(context, culture, value, destinationType);
        }

        #endregion

        #region Convert From Methods

        public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
        {
            return sourceType == typeof(WorkGroup);
        }

        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            WorkGroup state = (WorkGroup)value;

            //switch (state)
            //{
            //    case ToggleState.On:
            //        return 'Y';
            //    case ToggleState.Off:
            //        return 'N';
            //    case ToggleState.Indeterminate:
            //        return 'M';
            //}

            return base.ConvertFrom(context, culture, value);
        }

        #endregion
    }
}
